﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System;

namespace DNA.Mvc
{
    /// <summary>
    /// Defines the Command interface
    /// </summary>
    public interface ICommand
    {
        /// <summary>
        /// Identity this command is thread safe
        /// </summary>
        bool IsThreadSafe { get; }

        /// <summary>
        /// Gets the command execute order
        /// </summary>
        /// <remarks>
        /// This property only avaliable in command sequence mode. 
        /// </remarks>
        int Order { get; }

        /// <summary>
        /// Execute a command 
        /// </summary>
        /// <param name="context">The command context object</param>
        void Execute(ICommandContext context);

        /// <summary>
        /// Throw and exception on command execution.
        /// </summary>
        /// <param name="exception">The exception object</param>
        void OnError(Exception exception);

    }
}
